<%--
  Created by IntelliJ IDEA.
  User: guanjianjie
  Date: 2020/12/31
  Time: 10:44 下午
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<html>
<head>
    <link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="/static/js/runtask.js"></script>
    <script src="/static/js/allcode.js"></script>
    <title>运行任务</title>
</head>
<body>
<div>
    <c:import url="casenavit.jsp" charEncoding="UTF-8"/>

    <div class="col-sm-3 col-md-10">
        <div class="table-responsive">
            <table class="table table-striped">
                <thead>
                <tr>
                    <th style="text-align:center">任务id</th>
                    <th style="text-align:center">任务名称</th>
                    <th style="text-align:center">运行状态</th>
                    <th style="text-align:center">运行周期/分钟</th>
                    <th style="text-align:center">关联case数</th>
                    <th style="text-align:center">创建时间</th>
                    <th style="text-align:center">操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${runTasks}" var="runtask">
                    <tr>
                        <td style="text-align:center">${runtask.id}</td>
                        <td style="text-align:center;width:180px; height:51px; word-wrap:break-word; word-break:break-all">
                            ${runtask.taskname}
                        </td>
                        <c:choose>
                            <c:when test="${runtask.taskstatus == 1}">
                                <td style="text-align:center">运行中</td>
                                <c:set value="暂停" var="taskstatuname" />
                                <c:set value="2" var="pausetaskstatus" />
                            </c:when>
                            <c:otherwise>
                                <td style="text-align:center">暂停</td>
                                <c:set value="启动" var="taskstatuname" />
                                <c:set value="1" var="pausetaskstatus" />
                            </c:otherwise>
                        </c:choose>
                        <td style="text-align:center">${runtask.runcycle}</td>
                        <td style="text-align:center">${runtask.casenumber}</td>
                        <fmt:formatDate type="both" value="${runtask.createtime}" var="createtime" />
                        <td style="text-align:center">${createtime}</td>
                        <td style="text-align:center">
                            <div class="btn-group" role="group" aria-label="...">
                                <button type="button" class="btn btn-default" onclick="gettaskheml(${runtask.id})">编辑</button>
                                <button type="button" class="btn btn-default" onclick="pausetask(${runtask.id},${pausetaskstatus})">${taskstatuname}</button>
                                <button type="button" class="btn btn-default" onclick="deltaskmodel(${runtask.id})">删除</button>
                                <button type="button" class="btn btn-default">立即运行</button>
                            </div>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </div>
    <div>
        <button class="btn btn-default" type="submit" onclick="goaddtaskmodelhtml()">新建任务</button>
    </div>
</div>
<div name="allmodel">
    <div name="addruntask">
        <div class="modal fade" id="addruntaskmodel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-body">
                        <form class="form-horizontal" role="form">
                            <h5 id="addtaskid" style="display: none">-1</h5>
                            <h5 id="addprojectid" style="display: none">${projectid}</h5>
                            <div class="form-group">
                                <label for="addtaskname" class="col-sm-2 control-label">任务名称:</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="addtaskname"
                                           placeholder="请输入任务名称">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="addruncycle" class="col-sm-2 control-label">运行周期:</label>
                                <div class="col-sm-10">
                                    <input value="5" type="text" class="form-control" id="addruncycle"
                                           placeholder="请输入运行周期/单位分钟,范围5~59分钟">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="addcallnumber" class="col-sm-2 control-label">报警工号:</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="addcallnumber"
                                           placeholder="请输入要通知的报警工号,用,号分隔">
                                </div>
                            </div>
<%--                            <div>--%>
<%--                                <label>关联的case:</label>--%>
<%--                                <select style="height: 300px" id="taskcaseselectall" multiple class="form-control">--%>
<%--                                    <c:forEach items="${caseinfoWebs}" var="caseinfoweb">--%>
<%--                                        <option value="${caseinfoweb.caseid}">${caseinfoweb.casename}</option>--%>
<%--                                    </c:forEach>--%>
<%--                                </select>--%>
<%--                            </div>--%>
                            <div id="checkcasetaskid">
                                <label>关联的case:</label>
                                    <c:forEach items="${caseinfoWebs}" var="caseinfoweb">
                                        <div name="checkcasetaskname" class="checkbox">
                                            <label><input type="checkbox" value="${caseinfoweb.caseid}">${caseinfoweb.casename}</label>
                                        </div>
                                    </c:forEach>
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <h5 id="taskmessage"></h5>
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                        </button>
                        <button onclick="addtaskhtml()" type="button" class="btn btn-primary">
                            提交更改
                        </button>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal -->
        </div>
    </div>

    <div>
        <div class="modal fade" id="messagemodel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-body">
                        <h5 id="httpmessageid"></h5>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal -->
        </div>
    </div>


    <div class="modal fade" id="delinterinfoModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <h5 id="deltaskidmodel" style="display: none"></h5>
                <div class="modal-body">
                    是否确定删除
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                    </button>
                    <button type="button" class="btn btn-primary" onclick="deltaskinfohttp()">确定</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>

</div>


</body>
</html>
